/**
 * 修改计划时加载数据
 */
function edit(){
	if(act != "edit" && act != "draft")return;
	// 给计划表单控件赋值
	$.blockUI({message : "数据载入中,请稍候..."});
	$.ajax({
		url : webRoot + 'baseconfig/dmplan/qryRecordInfo.do',
		type : 'POST',
		async : true,
		data : {dmPlanId:plan}
	}).done(function(serverData, textStatus, jqXHR) {
		$('input[name="planName"]').val(serverData.planName);//计划名称
		//所属系统
		var node = $.fn.zTree.getZTreeObj("nodeId_tree").getNodeByParam("id", serverData.nodeId);
		if(node != null){
			$('input[name="nodeId"]').attr("vId",node.id);
			$('input[name="nodeId"]').val(node.name);
		}
		var sourceType = serverData.sourceType;//源数据类型
		$("input[name='sourceType'][value="+sourceType+"]").attr("checked",true); 
		if(sourceType==1){
			$("#targetType,#analyseFlag").show();
		}else if(sourceType==2){
			$("#targetType,#analyseFlag").hide();
		}
		var execType = serverData.execType;//执行类型
		$("input[name='execType'][value="+execType+"]").attr("checked",true); 
		if(execType==1){
			/*if(serverData.execFrequency == "1"){// 执行频率：单次执行
				$("#execFrequency,#startTime").show();
			}else{*/
				$("#execFrequency,#cycleType,#startTime,#specialDay").show();
//				$('input[name=cycleDay]').removeAttr('novalidate');
				$('input[name=cycleDay]').attr('data-rule','required');
			//}
				
				$('input[name=cycleDay]').attr('data-rule','required');
				$("input[name=cycleDay]").attr('data-rule','').resetValid();
				
				
//			$('input[name=startTime]').removeAttr('novalidate');
				$('input[name=startTime]').attr('data-rule','required');
			$("input[name='execFrequency'][value="+serverData.execFrequency+"]").attr("checked",true);//执行频率
			if(serverData.execFrequency ==0){
				$("#cycleType,#specialDay").show();
//				$('input[name=cycleDay]').removeAttr('novalidate');
				$('input[name=cycleDay]').attr('data-rule','required');
			}else if(serverData.execFrequency ==1){
				$("#cycleType,#specialDay").hide();
//				$("input[name=cycleDay]").attr('novalidate','novalidate').resetValid();
				$("input[name=cycleDay]").attr('data-rule','').resetValid();
			}
			$("input[name='cycleType'][value="+serverData.cycleType+"]").attr("checked",true);//循环方式
			$('input[name="cycleDay"]').val(serverData.cycleDay);//循环周期
			// 执行时间
			if (serverData.cycleType == 0) {
				$('input[name="startTime"]').datetimepicker('destroy').val(serverData.startTime.substring(0,2) + '日' + serverData.startTime.substring(2,4) + ':' + serverData.startTime.substring(4,6) + ':00').datetimepicker({
					buttonIcon : 'calendar',
					viewType : 'datetime',
					format : 'dd日hh:ii:ss',
					initialDate:new Date(2016, 4, serverData.startTime.substring(0,2), serverData.startTime.substring(2,4), serverData.startTime.substring(4,6)),
					startDate:new Date(2016, 4, 2, 0),
					endDate:new Date(2016, 4, 31, 23, 59),
					container:'#startTimeBox',
					autoClose: true
				});
			} else {
				$('input[name="startTime"]').datetimepicker('destroy').val(serverData.startTime.substring(2,4) + ':' + serverData.startTime.substring(4,6) + ':00').datetimepicker({
					buttonIcon : 'time',
					viewType : 'time',
					format : 'hh:ii:ss'
				});
			}
			if(serverData.specialDay != null){
				var ids = serverData.specialDay.split(",");
				$('select[name="specialDay"]').multiselect('value', ids);//排除日期
			}
		}else if(execType==2){
			/*if(serverData.execFrequency == "1"){// 执行频率：单次执行
				$("#execFrequency,#startTime").hide();
			}else{*/
				$("#execFrequency,#cycleType,#startTime,#specialDay").hide();
			//}
//			$("input[name=startTime]").attr('novalidate','novalidate').resetValid();
			$("input[name=startTime]").attr('data-rule','').resetValid();
			$("input[name=cycleDay]").attr('data-rule','').resetValid();
//			$("input[name=cycleDay]").attr('novalidate','novalidate').resetValid();
		}
		$("input[name='targetType'][value="+serverData.targetType+"]").attr("checked",true);//目标数据类型
		var operType = serverData.operType;
		oldOperType = serverData.operType;
//		$('input[name="operType"]').combobox({value:operType+""});//下拉框操作类型赋值
		$('input[name="operType"]').combobox('value',operType+"");//下拉框操作类型赋值
		if(operType == "2"){
			$("#needCheck,#tableAnalyseFlag,#indexAnalyseFlag").hide();
		}else{
			$("#needCheck,#tableAnalyseFlag,#indexAnalyseFlag").show();
		}
//		$('input[name="tableAnalyseFlag"][value="' + serverData.tableAnalyseFlag + '"]').attr("checked",true);//清理后执行表分析
//		$('input[name="indexAnalyseFlag"][value="' + serverData.indexAnalyseFlag + '"]').attr("checked",true);//清理后执行索引分析
		
		if(serverData.tableAnalyseFlag!="1"){
			$('input[name="tableAnalyseFlag"]').attr("checked",false);//清理后执行表分析
		}
		if(serverData.indexAnalyseFlag!="1"){
			$('input[name="indexAnalyseFlag"]').attr("checked",false);//清理后执行索引分析
		}
		$("input[name='needCheck'][value="+serverData.needCheck+"]").attr("checked",true);//清理方式
		$('input[name="effDate"]').val(serverData.effDate.substring(0,serverData.effDate.indexOf(' ')));//生效时间
		$('input[name="expDate"]').val(serverData.expDate.substring(0,serverData.expDate.indexOf(' ')));//失效时间
		$('textarea[name="planDesc"]').val(serverData.planDesc);//描述
		// //给策略组赋值
		// $.fn.zTree.init($("#tree"), setting(plan));
	}).fail(function() {
		fish.toast('error', "网络连接失败！");
	}).always(function() {
		$.unblockUI();
	});
}